<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> 
<head>
<%@ include file="../../include/easyui.jsp" %>
<%@ include file="../../include/pGrid.jsp" %>
<script type="text/javascript" src="/plug-in/jquery-easyui-1.5.1/datagrid-detailview.js"></script>
<title>项目管理统计</title>
<script>
	$(function(){
		p.className = "com.fs.jzzn.pojo.NewProject";
		var gridParam = {
			url:'/console/com.fs.jzzn.pojo.NewProject/list',
			queryParams:{
				rightControl: true //启用数据权限控制
			},
			//fitColumns:true,
			columns : [[ 
			     {field: 'pNo', title: '项目编号', width: 120} 
		    	,{field: 'pName', title: '项目名称', width: 300}
		    	,{field: 'department', title: '项目部', width: 200}
		    	,{field: 'region', title: '所属区域', width: 120}
		    	,{field: 'createTime', title: '创建时间', width: 150}
		    	,{field: 'createrName', title: '创建人', width: 120}
			]],
			onLoadSuccess: function(){
				p.tooltip('pName');
			},
			view: detailview,
			detailFormatter:function(index,row){
				return '<div class="details" style="padding:5px 0;min-height:200px;"></div>';
			},
			onExpandRow:function(index,row){
				var ddv = $(this).datagrid('getRowDetail',index).find('div.details');
				var detailGrid = ddv.datagrid({
					url : '/console/com.fs.jzzn.pojo.Project/list',
					queryParams: {
						pName:row.pName,
						pName_searchType: "eq"
					},
					title:'子单项工程列表-'+ row.pNo,
					pageSize:30,
					rownumbers: true,
					pagination: true,
					singleSelect: true, 
					columns : [[
						{field: 'pNo', title: '工程路段编号', width: 130} 
						,{field: 'pRoad', title: '工程段落', width: 270}
						,{field: 'status', title: '项目状态', width: 120}
						,{field: 'pType', title: '专业类别', width: 80}
						,{field: 'contractNo', title: '订单编号', width: 240}
						,{field: 'pName', title: '项目名称', width: 250}
						,{field: 'budgetMoney', title: '立项预算', width: 90}
						,{field: 'actualMoney', title: '完工预算', width: 90}
						,{field: 'designLength', title: '设计长度', width: 80}
						,{field: 'pm', title: '项目经理', width: 100}
						,{field: 'marketManager', title: '市场负责人', width: 100}
						,{field: 'constructionUnit', title: '建设单位', width: 200}
						,{field: 'designUnit', title: '设计单位', width: 120}
						,{field: 'operator', title: '运营商', width: 120}
						,{field: 'ppm', title: '工程经理', width: 120}
						,{field: 'orgNo', title: '所属机构', width: 180,formatter: function(value,row,index){
							return (value || '') + '-' + (row.orgNoName|| '') ;
						}}
						,{field: 'pCreateDate', title: '订单日期', width: 120}
						,{field: 'subpackage', title: '是否分包', width: 120}
						,{field: 'subpackageScale', title: '分包比例', width: 120}
						,{field: 'region', title: '区域', width: 120}
						,{field: 'priority', title: '优先级', width: 120}
						,{field : 'remark',width : 150,title: '备注'}
						,{field: 'createTime', title: '创建时间', width: 130}
						,{field: 'createrName', title: '创建人', width: 120}
					]],
					onLoadSuccess:function(){
						p.tooltip(['pRoad','contractNo','pName']);
						$('#dataGrid').datagrid('fixDetailRowHeight',index);
						var dData = detailGrid.datagrid('getData');
						var total = {budgetMoney:0,actualMoney:0,designLength: 0,pName:'合计：'};
						$.each(dData.rows ||[], function (i,item) {
							total.budgetMoney += parseFloat(item.budgetMoney || '0');
							total.actualMoney += parseFloat(item.actualMoney || '0');
							total.designLength += parseFloat(item.designLength || '0');
						});
						total.budgetMoney = total.budgetMoney.toFixed(2);
						total.actualMoney = total.actualMoney.toFixed(2);
						total.designLength = total.designLength.toFixed(2);
						detailGrid.datagrid('appendRow',total);
					},
					toolbar: [
				          { iconCls: 'icon-excel', text:'项目子单项工程导出',handler: function(){
					        	  p.down({
					        		  filename: row.pName,local :true,grid:detailGrid,
					        		  url:'/console/project/export' ,
					        	 });
				          }}
					]
				});
			}
		};
		p.dataGrid = $(p.dataGrid).datagrid( $.extend({}, p.dataGridParam,gridParam));
		/*事件响应*/
		$("#toolbar .easyui-linkbutton").on("click", function() {
			var motion_code = $(this).attr("motion_code");p.btnOneClick($(this));
			switch (motion_code) {
				case "05":
					p.gridQuery();
					break;
				default:
					break;
				}
		});
	});
</script>
</head>
<body class="easyui-layout">
	<!-- 但行高度33px，多行时 33乘以行数  -->
	<div data-options="region:'north',split:false,border:false" style="height:33px;">
		<div class="easyui-panel" data-options="fit:true,border:false">
			<!-- 查询条件表单，根据配置进行替换  -->
			<form id="queryForm" >
				 <input type="hidden" name="className" value="com.fs.jzzn.pojo.NewProject" />
				 <div style="margin-top:5px;margin-left:10px;float:left;">
				  <input class="easyui-textbox" name="pNo" style="width:240px;" data-options="label:'项目编号:',required:false" />
				<input type="hidden" name="pNo_searchType" value="like" />
				 </div>
				 <div style="margin-top:5px;margin-left:10px;float:left;">
				  	<input class="easyui-textbox" name="pName" style="width:240px;" data-options="label:'项目名称:',required:false" />
					<input type="hidden" name="pName_searchType" value="like" />
				 </div>
				 <div style="margin-top:5px;margin-left:10px;float:left;">
				  	 <select class="easyui-combobox" name="department" style="width:240px;" data-options="label:'项目部:'" 
						url="/console/combobox?valueField=dicName&textField=dicName&modleName=dictionary&pCode=A5&pCode_searchType=eq" >
				 	</select>
					<input type="hidden" name="department_searchType" value="like" />
				 </div>
			</form>
		</div>
	</div>  

	<!-- 工具栏按钮 -->
	<div id="toolbar" class="easyui-panel" style="padding:3px;"></div>
	
	<!-- 表格 -->
	<div region="center" border="false">
		<table id="dataGrid"></table>
	</div>
</body>
</html>